#!/usr/bin/env node

const fs = require('fs'),
      src = process.argv[2],
      target = process.argv[3];

if(!fs.existsSync(src)){
  console.error(`${src} is not exist!`);
  process.exit(1);
}

//复制文件内容
/*let target_content = fs.createReadStream(src).pipe(fs.createWriteStream(target));*/
let length = fs.statSync(src).size,
    buf = Buffer.alloc(length),
    fid = fs.openSync(src,'r'),
fs.readSync(fid,buf);
fs.writeSync(fid,buf.toString('utf8'),target);

//复制文件权限
/*target_content.on('close',() => {*/
  //fs.chmodSync(target,fs.statSync(src).mode);
/*});*/
